home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
tools
/
czesc_3
/
phoonsrc
/
dtime.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-23
|
2KB
|
68 lines
#ifndef lint
static char rcsid[] =
"@(#) $Header: dtime.c,v 1.3 88/08/26 22:29:38 jef Exp $ (LBL)";
#endif
/*
** Copyright (C) 1988 by Jef Poskanzer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted, provided
** that the above copyright notice appear in all copies and that both that
** copyright notice and this permission notice appear in supporting
** documentation. This software is provided "as is" without express or
** implied warranty.
*/
/* dtime.c - extracted from the phoon/libtws package
*/
#include "tws.h"
#include <sys/types.h>
#include <time.h>
unsigned long atime( unsigned long * );
struct tm * alocaltime( unsigned long *);
struct tws *adlocaltime( unsigned long * clock);
extern short gmtoffset; /* hmmm */
struct tws *
dtwstime( )
{
unsigned long clock;
(void) atime( &clock );
return ( adlocaltime( &clock ) );
}
struct tws *
adlocaltime( unsigned long * clock)
{
register struct tm *tm;
static struct tws tw;
if ( clock == NULL )
return ( NULL );
tw.tw_flags = TW_NULL;
tm = alocaltime( clock );
tw.tw_sec = tm -> tm_sec;
tw.tw_min = tm -> tm_min;
tw.tw_hour = tm -> tm_hour;
tw.tw_mday = tm -> tm_mday;
tw.tw_mon = tm -> tm_mon;
tw.tw_year = tm -> tm_year;
tw.tw_wday = tm -> tm_wday;
tw.tw_zone = -gmtoffset;
tw.tw_flags &= ~TW_SDAY;
tw.tw_flags |= TW_SEXP;
tw.tw_clock = *clock + (8 * 365 + 2) * 24 * 3600;
return ( &tw );
}